mongoexport |
您所在的位置:网站首页 › mongodump mongoexport › mongoexport |
Behavior¶
Type Fidelity¶
Warning Avoid using mongoimport and mongoexport for full instance production backups. They do not reliably preserve all rich BSON data types, because JSON can only represent a subset of the types supported by BSON. Use mongodump and mongorestore as described in MongoDB Backup Methods for this kind of functionality. Starting in version 4.2, mongoexport: Outputs data in Extended JSON v2.0 (Relaxed mode) by default. Outputs Extended JSON v2.0 (Canonical mode) if used with --jsonFormat.Earlier versions used Extended JSON v1.0 (Canonical mode). For example, the following insert operation in the mongo shell uses the various shell helpers for the BSON types Date and 64-bit integer: copy use test db.traffic.insert( { _id: 1, volume: NumberLong('2980000'), date: new Date() } )The argument to 64-bit integer must be quoted to avoid potential loss of accuracy. Use mongoexport to export the data: copy mongoexport --db=test --collection=traffic --out=traffic.jsonIn version 4.2+, the exported data is in Extended JSON v2.0 (Relaxed mode). copy {"_id":1.0,"volume":2980000,"date":{"$date":"2019-08-05T16:18:29.559Z"}}To output in Extended JSON v2.0 (Canonical mode), include the --jsonFormat=canonical: copy mongoexport --db=test --collection=traffic --jsonFormat=canonical --out=traffic.jsonThe exported data is in Extended JSON v2.0 (Canonical mode): copy {"_id":{"$numberDouble":"1.0"},"volume":{"$numberLong":"2980000"},"date":{"$date":{"$numberLong":"1565363188675"}}}In version 4.0 and earlier, the exported data is in Extended JSON v1.0 (Strict mode) copy {"_id":1.0,"volume":{"$numberLong":"2980000"},"date":{"$date":"2019-08-05T16:18:29.559Z"}} FIPS¶Starting in version 4.2, MongoDB removes the --sslFIPSMode option for mongoexport. mongoexport will use FIPS compliant connections to mongod/mongos if the mongod/mongos instances are configured to use FIPS mode. Read Preference¶By default, mongoexport uses read preference primary. To override the default, you can specify the read preference in the --readPreference command line option or in the --uri connection string. Starting in version 4.2, if you specify read preference in the URI string and the --readPreference, the --readPreference value overrides the read preference specified in the URI string. In earlier versions, the two options are incompatible. |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |